package com.liu.susu.thread.task.scheduled.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @FileName MyScheduledConfig
 * @Description
 * @Author susu
 * @date 2022-03-11
 **/
@Configuration
@Slf4j
//注意：不要在这个配置类里加定时任务，不会生效的，其他配置类可以！！
public class MyScheduledConfig {

//    @Conditional(MyScheduledCondition.class)
    @ConditionalOnProperty(value = "susu.task.isOpen")
    @Bean
    public ScheduledAnnotationBeanPostProcessor createScheduled(){
        return new ScheduledAnnotationBeanPostProcessor();
    }


}
